//
//  CheckBoxCell.m
//  Project6
//
//  Created by ToanDK on 11/23/12.
//  Copyright (c) 2012 DungNP. All rights reserved.
//

#import "CheckBoxCell.h"


@implementation CheckBoxCell
@synthesize  checkBoxLable;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
//        checkBoxLable.userInteractionEnabled = NO;
    }
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
       
    
}

-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
    [self.contentView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"cellLigthPartern"]]];
    [self setBackgroundView:nil];
    [self setBackgroundColor:[UIColor clearColor]];
    
    if (self.isChecked)
    {
        self.changeStateButton.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cellGreenPartern.png"]];
       
    }
    else
        self.changeStateButton.backgroundColor = [UIColor clearColor];
     
}

-(IBAction)changeState_Click:(UIButton*)sender
{
      NSLog(@"changeState_Click");
      if(!self.isChecked)
      {
         sender.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cellGreenPartern.png"]];
          
          self.isChecked = TRUE;
          [self.rootController setStatusForCell:YES Tag:self.changeStateButton.tag];
      }
      else
      {
          sender.backgroundColor = [UIColor clearColor];
          self.isChecked = FALSE;
          [self.rootController setStatusForCell:NO Tag:self.changeStateButton.tag];
      }
    
}
// change background
-(void) setStatusForCell:(BOOL)checked
{
    if (checked) {
        self.isChecked = TRUE;
    }
    else
    {
        self.isChecked = FALSE;
         
    }
}

@end
